#include<stdio.h> 
#include<math.h> 

double jl(double x1,double y1,double x2,double y2)   
{ 
double a; 
a=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
return a;
}

int main() 
{ 
  int i,n;
int x1,y1,x2,y2,temp1,temp2;
  double f[201][201]={0.0},sum,s1,s2,s3;
for(i=0;i<=200;i++)
  { 
f[i][0]=f[0][i]+jl(0,i,i,0);
  f[0][i+1]=f[i][0]+jl(i,0,0,i+1);
  }
scanf("%d",&n);
while(n--) 
{ scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
  s1=0; s2=0; sum=0;
  if(x1+y1> x2+y2)
  { 
    temp1=x1;x1=x2;x2=temp1;
    temp2=y1;y1=y2;y2=temp2;
  } 
  s1=jl(x1,y1,0,x1+y1);y1+=x1;x1=0;s1+=f[x1][y1];
  s2=jl(x2,y2,0,x2+y2);y2+=x2;x2=0;s2+=f[x2][y2];
  sum=s2-s1;
  printf("%.3lf\n",sum); 
} 
return 0;
} 